package ru.tulupov.quadraticequation;

import java.util.ArrayList;
import java.util.List;

/**
 * Quadratic equation solver
 * 
 * @author <a href="mailto:zhekka3@gmail.com">Eugene Tulupov</a>
 */
public class QuadraticEquation {
	private static final double EPSILON = 1e-9;

	private double a;
	private double b;
	private double c;

	/**
	 * Constructs a quadratic equation object.<br>
	 * A quadratic equation can be written in the form<br>
	 * <b>Ax^2 + Bx + C = 0</b>.
	 * 
	 * @param a
	 *            the A coefficient.
	 * @param b
	 *            the B coefficient.
	 * @param c
	 *            the C coefficient.
	 * @throws InvalidQuadraticEquation
	 */
	public QuadraticEquation(double a, double b, double c) {
		if (Math.abs(a) < EPSILON) {
			throw new InvalidQuadraticEquation();
		}

		this.a = a;
		this.b = b;
		this.c = c;
	}

	public double getA() {
		return a;
	}

	public double getB() {
		return b;
	}

	public double getC() {
		return c;
	}

	
	/**
	 * Returns string representation of quadratic equation
	 */
	@Override
	public String toString() {
		return String.format("%f*x^2 + %f*x + %f = 0", a, b, c);
	}
}
